/* ************************************************************************ */
/*                                                                          */
/*  kyototycoon-neko														*/
/*  HaXe/neko Library													    */
/*  Copyright (c)2011 François Nicaise                                      */
/*                                                                          */
/*  This program is free software; you can redistribute it and/or modify    */
/*  it under the terms of the GNU General Public License as published by    */
/*  the Free Software Foundation; either version 2 of the License, or       */
/*  (at your option) any later version.                                     */
/*                                                                          */
/*  This program is distributed in the hope that it will be useful,         */
/*  but WITHOUT ANY WARRANTY; without even the implied warranty of          */
/*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           */
/*  GNU General Public License for more details.                            */
/*                                                                          */
/*  You should have received a copy of the GNU General Public License       */
/*  along with this program; if not, write to the Free Software             */
/*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*                                                                          */
/* ************************************************************************ */
package kt;

class Object {

	public var key : String;
	public var xt : Int;	// expiration time

	var local_manager : {
		private function doSet( o : Object) : Void;
		private function doReplace( o : Object ) : Void;
		private function doRemove( o : Object ) : Bool;
	};

	public function new() {
	}

	/**
	 * Insert the information in the database. 
	 * If no key specified, will give one automatically using increment method
	 */
	public function insert( ) {
		local_manager.doSet( this  );
	}

	/**
	 * Replace the information in the database. 
	 */
	public function update() {
		local_manager.doReplace( this );
	}

	/*
	 * Returns true of anything was deleted
	 */
	public function delete() : Bool {
		return local_manager.doRemove( this );
	}
	
}
